package com.grayson.wordsfilter.controller;

import com.grayson.wordsfilter.service.SensitiveWordService;
import com.grayson.wordsfilter.vo.CommonResponse;
import com.grayson.wordsfilter.vo.ContentProcessReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * SensitiveWordController
 *
 * @Description:
 * @Author: grayson
 * @Version 1.0
 * @Date: 2023-05-11 22:56
 **/
@RestController
@Api("sensitive word api")
@RequestMapping(value = "/word")
public class SensitiveWordController {

    @Autowired
    private SensitiveWordService sensitiveWordService;

    @ApiOperation("replace sensitive word")
    @PostMapping("/replace")
    public CommonResponse replaceSensitive(@RequestBody @Valid ContentProcessReq req){
        return sensitiveWordService.replace(req.getContent());
    }

    @ApiOperation("whether exists sensitive word")
    @PostMapping("/exist")
    public CommonResponse existSensitive(@RequestBody @Valid ContentProcessReq req){
        return sensitiveWordService.exist(req.getContent());
    }
}